﻿namespace RL
{
    
    using System;
    using System.Text;
    using System.Web.UI;

    public class JQuery
    {
        private RL.AjaxPlaceHolder manager;

        public JQuery(RL.AjaxPlaceHolder Manager)
        {
            this.manager = Manager;
        }

        public static string AddClass(string Selector, string cssClass, bool terminate)
        {
            return ("$(" + Selector + ").addClass('" + cssClass + "')" + utility.terminater(terminate));
        }

        public static string AnonymousFuncStubEnd()
        {
            StringBuilder sb = new StringBuilder();
            utility.sbAppp(sb, "}");
            utility.sbAppp(sb, "); ");
            return sb.ToString();
        }

        public static string AnonymousFuncStubStart()
        {
            StringBuilder sb = new StringBuilder();
            utility.sbAppp(sb, " $(");
            utility.sbAppp(sb, "function(){");
            return sb.ToString();
        }

        public static string Css(string selector, bool terminate, params string[] CssPropValuePairs)
        {
            string sourceString = "$(" + selector + ").css({";
            for (int i = 0; i < CssPropValuePairs.Length; i += 2)
            {
                string str3 = sourceString;
                sourceString = str3 + CssPropValuePairs[i] + ":" + CssPropValuePairs[i + 1] + ",";
            }
						return ("".TrimEnd(sourceString, ",", true) + "})" + utility.terminater(terminate));
        }

        public static string Css(string selector, string cssSelector, bool terminate)
        {
            return ("$(" + selector + ").css(" + cssSelector + ")" + utility.terminater(terminate));
        }

        public static string Css(string Selector, HtmlTextWriterStyle Property, string val, bool terminate)
        {
            return ("$(" + Selector + ").css(" + Property.ToString() + "," + val + ")" + utility.terminater(terminate));
        }

        public static string DocumentReady(string code)
        {
            return Event("document", "ready", code);
        }

        public static string DomReadyStubEnd()
        {
            return " }); ";
        }

        public static string DomReadyStubStart()
        {
            return "$(document).ready(function() {";
        }

        public static string Event(string Selector, RL.AjaxPlaceHolder.HtmlEvent Event, string code)
        {
            return (EventStubStart(Selector, Event.ToString()).ToString() + code.ToString() + EventStubEnd().ToString());
        }

        public static string Event(string Selector, string Event, string code)
        {
            return (EventStubStart(Selector, Event) + code + EventStubEnd());
        }

        public static string EventStubEnd()
        {
            return " } );";
        }

        public static string EventStubStart(string Selector, RL.AjaxPlaceHolder.HtmlEvent Event)
        {
            return ("$(" + Selector + ").bind(\"" + Event.ToString() + "\", function () {");
        }

        public static string EventStubStart(string Selector, string Event)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("$(");
            builder.Append(Selector);
            builder.Append(").bind(\"");
            builder.Append(Event);
            builder.Append("\", function () {");
            return builder.ToString();
        }

        public static string FadeIn(string selector, speed Speed, bool terminate)
        {
            return ("$(" + selector + ").fadeIn('" + Speed.ToString() + "')" + utility.terminater(terminate));
        }

        public static string FadeOut(string selector, bool terminate)
        {
            return ("$(" + selector + ").fadeOut()" + utility.terminater(terminate));
        }

        public static string FadeOut(string selector, speed Speed, bool terminate)
        {
            return ("$(" + selector + ").fadeOut('" + Speed.ToString() + "')" + utility.terminater(terminate));
        }

        public static string FadeTo(string selector, speed Speed, decimal opacity, bool terminate)
        {
            return ("$(" + selector + ").fadeTo('" + Speed.ToString() + "', " + opacity.ToString() + ")" + utility.terminater(terminate));
        }

        public static string FadeTo(string selector, int time, decimal opacity, bool terminate)
        {
            return ("$(" + selector + ").fadeTo(" + time.ToString() + ", " + opacity.ToString() + ")" + utility.terminater(terminate));
        }

        public static string FunctionAnonymous(string code)
        {
            return (AnonymousFuncStubStart() + code.ToString() + AnonymousFuncStubEnd());
        }

        public static string FunctionAnonymous(StringBuilder code)
        {
            return (AnonymousFuncStubStart() + code.ToString() + AnonymousFuncStubEnd());
        }

        public static string height(string Selector, bool terminate)
        {
            return ("$(" + Selector + ").height()" + utility.terminater(terminate));
        }

        public static string height(string Selector, int height, bool terminate)
        {
            return ("$(" + Selector + ").height(" + height.ToString() + ")" + utility.terminater(terminate));
        }

        public static string Hide(string selector, bool terminate)
        {
            return ("$(" + selector + ").hide()" + utility.terminater(terminate));
        }

        public static string Hide(string selector, speed Speed, bool terminate)
        {
            return ("$(" + selector + ").hide('" + Speed.ToString() + "')" + utility.terminater(terminate));
        }

        public static string html(string selector, string text, bool terminate)
        {
            return ("$(" + selector + ").html(' " + text + "')" + utility.terminater(terminate));
        }

        public static string OffSet(string selector, bool terminate)
        {
            return ("$(" + selector + ").offset()" + utility.terminater(terminate));
        }

        public static string RemoveClass(string Selector, bool terminate)
        {
            return ("$(" + Selector + ").removeClass()" + utility.terminater(terminate));
        }

        public static string RemoveClass(string Selector, string cssClass, bool terminate)
        {
            return ("$(" + Selector + ").removeClass('" + cssClass + "')" + utility.terminater(terminate));
        }

        public static string SelectAll(string name)
        {
            return "'*'";
        }

        public static string SelectAttributeWithValue(string element, string attrib, string val)
        {
            return ("'" + element + "[" + attrib + "='" + val + "']'");
        }

        public static string SelectChildren(string element1, string element2)
        {
            return ("'" + element1 + ">" + element2 + "'");
        }

        public static string SelectClass(string name)
        {
            return ("'." + name + "'");
        }

        public static string SelectDescendant(string element1, string element2)
        {
            return ("'" + element1 + " " + element2 + "'");
        }

        public static string SelectElement(string name)
        {
            return ("'" + name + "'");
        }

        public static string SelectHasAttribute(string element, string attrib)
        {
            return ("'" + element + "[" + attrib + "]'");
        }

        public static string SelectId(string name)
        {
            return ("'#" + name + "'");
        }

        public static string SelectMultiple(params string[] elements)
        {
            string sourceString = "'";
            foreach (string str2 in elements)
            {
                sourceString = sourceString + str2 + ",";
            }
						return ("".TrimEnd(sourceString, ",", true) + "'");
        }

        public static string SelectNext(string element1, string element2)
        {
            return ("'" + element1 + " + " + element2 + "'");
        }

        public static string SelectSiblings(string element1, string element2)
        {
            return ("'" + element1 + " ~ " + element2 + "'");
        }

        public static string Show(string selector, bool terminate)
        {
            return ("$(" + selector + ").show()" + utility.terminater(terminate));
        }

        public static string Show(string selector, speed Speed, bool terminate)
        {
            return ("$(" + selector + ").show('" + Speed.ToString() + "')" + utility.terminater(terminate));
        }

        public static string SlideDown(string selector, bool terminate)
        {
            return ("$(" + selector + ").slideDown()" + utility.terminater(terminate));
        }

        public static string SlideDown(string selector, speed Speed, bool terminate)
        {
            return ("$(" + selector + ").slideDown('" + Speed.ToString() + "')" + utility.terminater(terminate));
        }

        public static string SlideToggle(string selector, bool terminate)
        {
            return ("$(" + selector + ").slideToggle()" + utility.terminater(terminate));
        }

        public static string SlideUp(string selector, bool terminate)
        {
            return ("$(" + selector + ").slideUp()" + utility.terminater(terminate));
        }

        public static string SlideUp(string selector, speed Speed, bool terminate)
        {
            return ("$(" + selector + ").slideUp('" + Speed.ToString() + "')" + utility.terminater(terminate));
        }

        public static string Toggle(string selector, bool terminate)
        {
            return ("$(" + selector + ").toggle()" + utility.terminater(terminate));
        }

        public static string width(string Selector, bool terminate)
        {
            return ("$(" + Selector + ").width()" + utility.terminater(terminate));
        }

        public static string width(string Selector, int width, bool terminate)
        {
            return ("$(" + Selector + ").width(" + width.ToString() + ")" + utility.terminater(terminate));
        }
    }
}

